<?php

/**
 * This is the model class for table "penderitahiv".
 *
 * The followings are the available columns in table 'penderitahiv':
 * @property integer $phiv_id
 * @property integer $phiv_kec
 * @property integer $phiv_laki
 * @property integer $phiv_perempuan
 * @property integer $phiv_jumlah
 * @property integer $phiv_meninggal
 * @property integer $phiv_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $phivKec
 */
class Penderitahiv extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Penderitahiv the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'penderitahiv';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('phiv_kec, phiv_laki, phiv_perempuan, phiv_jumlah, phiv_meninggal, phiv_tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('phiv_id, phiv_kec, phiv_laki, phiv_perempuan, phiv_jumlah, phiv_meninggal, phiv_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'phivKec' => array(self::BELONGS_TO, 'Kecamatan', 'phiv_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'phiv_id' => 'Phiv',
			'phiv_kec' => 'Phiv Kec',
			'phiv_laki' => 'Phiv Laki',
			'phiv_perempuan' => 'Phiv Perempuan',
			'phiv_jumlah' => 'Phiv Jumlah',
			'phiv_meninggal' => 'Phiv Meninggal',
			'phiv_tahun' => 'Phiv Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('phiv_id',$this->phiv_id);
		$criteria->compare('phiv_kec',$this->phiv_kec);
		$criteria->compare('phiv_laki',$this->phiv_laki);
		$criteria->compare('phiv_perempuan',$this->phiv_perempuan);
		$criteria->compare('phiv_jumlah',$this->phiv_jumlah);
		$criteria->compare('phiv_meninggal',$this->phiv_meninggal);
		$criteria->compare('phiv_tahun',$this->phiv_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}